package com.six.goods.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.six.core.entity.Deposit;
import com.six.core.vo.Result;
import com.six.goods.mapper.DepositMapper;
import com.six.goods.service.DepositService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author wang
* @description 针对表【sto_deposit】的数据库操作Service实现
* @createDate 2023-02-27 15:19:48
*/
@Service
public class DepositServiceImpl extends ServiceImpl<DepositMapper, Deposit>implements DepositService {
    @Autowired
    private DepositMapper depositMapper;
    //储存--分页
    @Override
    public Result seleAllDeposit(Integer currentPage, Integer pageSize, Deposit deposit) {
        PageHelper.startPage(currentPage,pageSize);
        List<Deposit> deposits = depositMapper.seleAllDeposit(deposit);
        PageInfo<Deposit> pageInfo=new PageInfo<>(deposits);
        if (pageInfo != null){
            return new Result(2000 ,"查询成功",pageInfo);
        }
        return new Result(5000 ,"查询失败");
    }
    //储存--添加
    @Override
    public Result insertDeposit(Deposit deposit) {
        int i = depositMapper.insert(deposit);
        if (i>0){
            return new Result(2000,"添加成功");
        }else {
            return new Result(5000,"添加失败");
        }
    }
    //储存--删除
    @Override
    public Result deleteDeposit(Integer id) {
        int i = depositMapper.deleteById(id);
        if (i>0){
            return new Result(2000,"删除成功");
        }else {
            return new Result(5000,"删除失败");
        }

    }
    //储存--修改
    @Override
    public Result updateDeposit(Deposit deposit) {
        int i = depositMapper.updateById(deposit);
        if (i>0){
            return new Result(2000 ,"修改成功");
        }else {
            return new Result(5000,"修改失败");
        }

    }

    @Override
    public Result selectDeposit() {
        List<Deposit> deposits = depositMapper.selectList(null);
        if (deposits!=null){
            return new Result(2000,"查询成功",deposits);
        }else {
            return new Result(5000,"查询失败");
        }
    }

    @Override
    public Deposit selectDepositname(Deposit deposit) {
        Deposit deposit1 = depositMapper.selectDepositname(deposit);
        return deposit1;
    }

}




